#ifndef PARSETREE_H
#define PARSETREE_H

#include "value.h"

enum ParseTreeType
{
    PTTNoop,
    PTTArray,
    PTTAdd,
    PTTAddAssign,
    PTTAddressOf,
    PTTArg,
    PTTArrow,
    PTTAssign,
    PTTBitwiseAnd,
    PTTBitwiseAndAssign,
    PTTBitwiseNot,
    PTTBitwiseOr,
    PTTBitwiseOrAssign,
    PTTBitwiseXor,
    PTTBitwiseXorAssign,
    PTTBlock,
    PTTBreak,
    PTTCase,
    PTTCast,
    PTTContinue,
    PTTDereference,
    PTTDesignatorIndex,
    PTTDesignatorMember,
    PTTDivide,
    PTTDivideAssign,
    PTTDoWhile,
    PTTEllipsis,
    PTTElement,
    PTTEnumSpecifier,
    PTTEqual,
    PTTFor,
    PTTFuncCall,
    PTTFuncDef,
    PTTGreaterThan,
    PTTGreaterThanOrEqual,
    PTTGoto,
    PTTIf,
    PTTInitialiser,
    PTTLabel,
    PTTLessThan,
    PTTLessThanOrEqual,
    PTTLogicalAnd,
    PTTLogicalOr,
    PTTModulus,
    PTTModulusAssign,
    PTTMultiply,
    PTTMultiplyAssign,
    PTTNegate,
    PTTNot,
    PTTNotEqual,
    PTTPointer,
    PTTPostDec,
    PTTPostInc,
    PTTPreDec,
    PTTPreInc,
    PTTReturn,
    PTTSequence,
    PTTShiftLeft,
    PTTShiftLeftAssign,
    PTTShiftRight,
    PTTShiftRightAssign,
    PTTSizeof,
    PTTSpecifierQualifierList,
    PTTStructDeclaration,
    PTTStructDeclarator,
    PTTSubtract,
    PTTSubtractAssign,
    PTTSwitch,
    PTTTernaryOp,
    PTTTypeArrayDeclarator,
    PTTTypeAuto,
    PTTTypeBool,
    PTTTypeChar,
    PTTTypeComplex,
    PTTTypeDouble,
    PTTTypeExtern,
    PTTTypeFunction,
    PTTTypeImaginary,
    PTTTypeInline,
    PTTTypeInt,
    PTTTypeFloat,
    PTTTypeLong,
    PTTTypePointer,
    PTTTypeRegister,
    PTTTypeShort,
    PTTTypeSigned,
    PTTTypeStatic,
    PTTTypeStruct,
    PTTTypeTypedef,
    PTTTypeUnion,
    PTTTypeUnsigned,
    PTTTypeVoid,
    PTTUnaryPlus,
    PTTValue,
    PTTWhile
};

class ParseTree
{
    enum ParseTreeType TreeType;
    ParseTree *Left;
    ParseTree *Right;
    ParseTree *Up;

public:
    ParseTree();
    ParseTree(enum ParseTreeType t, ParseTree *l = NULL, ParseTree *r = NULL);
    ParseTree(enum ParseTreeType t, ParseTree *a, ParseTree *b, ParseTree *c);
    ParseTree(enum ParseTreeType t, ParseTree *a, ParseTree *b, ParseTree *c, ParseTree *d);

    // display the parse tree
    void Dump(int Level = 0);
};


class ParseTreeValue : public ParseTree
{
    Value *Val;

public:
    ParseTreeValue(Value *v) : ParseTree(PTTValue), Val(v) {};
};


// the parsed program
extern ParseTree *ProgramTree;

#endif /* PARSETREE_H */
